/**
 * shop vuex
 * 店铺模块
 */
const State = {
  // 店铺追踪数据缓存
  trail: {},
  // 店铺详情
  shop: {}
};

// getters
const Getters = {
  trail: state => state.trail,
  shop: state => state.shop
};

// mutations
const Mutations = {
  reset: state => {
    const s = {
      // 店铺追踪数据缓存
      trail: {},
      // 店铺详情
      shop: {}
    };
    Object.keys(s).forEach(key => {
      state[key] = s[key];
    });
  },
  SET_TRAIL: (state, trail) => {
    state.trail = { ...trail };
  },
  SET_SHOP: (state, shop) => {
    state.shop = { ...shop };
  }
};
// actions
const Actions = {
  storeTrail({ commit }, trail) {
    commit('SET_TRAIL', trail);
  },
  storeShop({ commit }, shop) {
    commit('SET_SHOP', shop);
  }
};

export default {
  namespaced: true,
  strict: true,
  state: State,
  getters: Getters,
  actions: Actions,
  mutations: Mutations
};
